<?php 
	if ($_FILES['foto_news']['name'] != "")
	{
		if ((($_FILES["foto_news"]["type"] == "image/gif")
		|| ($_FILES["foto_news"]["type"] == "image/jpeg")
		|| ($_FILES["foto_news"]["type"] == "image/png")
		|| ($_FILES["foto_news"]["type"] == "image/pjpeg"))
		&& ($_FILES["foto_news"]["size"] < 1050000))
		{
		$name = str_replace(" ", "_", $_FILES['foto_news']['name']);
		$random_digit=rand(0000,9999);
		$random_name = "news_".$random_digit.$name;
		
		$path = "../fotos/".$random_name;
		$img_link= "fotos/".$random_name;
		
		move_uploaded_file($_FILES["foto_news"]["tmp_name"], $path);
		
		$yuklandi = "Rasm ham yuklandi";
		
/************************ 
 ** Image resize block **
************************/
//include class file
			require('class.image-resize.php');
			$obj = new img_opt();
			// set maximum width within wich the image should be resized
			$obj->max_width(120);
			// set maximum height within wich the image should be resized
			// for example size of the area in which image to be displayed
			$obj->max_height(120);
			$obj->image_path($path);
			// call the functio to resize the image
			$obj->image_resize();
			
		/* End of Block */
		}
		else
		{
		$yuklanmadi = "<p class='error'> Xatolik, rasm olinmadi, <br>Chunki rasm faqat jpg, bmp, png, gif turdagi bo'lishi shart va <br> Rasm hajmi 1MB gacha bo'lishi lozim, <br>iltimos rasmingiz hajmini yoki fayl turini tekshiring</p>";
		}
	}
	else 
	{ $yuborilmadi =  "Siz rasm yubormadingiz";}
?>